package eu.scillman.net;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.SocketImpl;

/**
 * @deprecated Not yet supported!!
 * @author Jiri Waning
 *
 */
public class GenericSocket extends SocketImpl {
	/** The device that listens for incoming connection requests. **/
	private IServer server;
	
	/** The device that connects to remote devices. **/
	private IClient client;
	
	/**
	 * Create a new generic socket.
	 */
	public GenericSocket() {
		// Do something...
	}

	@Override
	public void setOption(int optID, Object value) throws SocketException {
		// TODO Auto-generated method stub
	}

	@Override
	public Object getOption(int optID) throws SocketException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void create(boolean stream) throws IOException {
		if (stream) {
			server = new eu.scillman.net.tcp.Server();
			client = new eu.scillman.net.tcp.Client();
		} else {
			server = new eu.scillman.net.udp.Server();
			client = new eu.scillman.net.udp.Client();
		}
	}

	@Override
	protected void connect(String host, int port) throws IOException {
		connect(InetAddress.getByName(host), port);
	}

	@Override
	protected void connect(InetAddress address, int port) throws IOException {
		client.connect(new Member(address, port));
	}

	@Override
	protected void connect(SocketAddress address, int timeout)
			throws IOException {
		// This approach by default uses a timeout!
	}

	@Override
	protected void bind(InetAddress host, int port) throws IOException {
		server.bind(new Member(host, port));
	}

	@Override
	protected void listen(int backlog) throws IOException {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void accept(SocketImpl s) throws IOException {
		// TODO Auto-generated method stub
	}

	@Override
	protected InputStream getInputStream() throws IOException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected OutputStream getOutputStream() throws IOException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected int available() throws IOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	protected void close() throws IOException {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void sendUrgentData(int data) throws IOException {
		// TODO Auto-generated method stub
		
	}

}
